<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>游戏得分排行榜</title>
	<script type="text/javascript" src="request.js"></script>
</head>
<body>
	<table border="1">
		<tbody id="tbody">
			<tr>
				<th>名次</th>
				<th>昵称</th>
				<th>头像</th>
				<th>得分</th>
			</tr>
		</tbody>
	</table>
</body>
<script type="text/javascript">

	var tbody = document.getElementById("tbody");
	requestByGET("get_rankingList.php",function(response){
		var userArray = JSON.parse(response);
		console.log(userArray);
		for(var i = 0; i < userArray.length; i++){
			var userInfo = userArray[i];
			var number = i+1;
			var nickname = userInfo.nickname;
			var headURL = userInfo.headimgurl;
			var score = userInfo.score;
			var trObj = document.createElement("tr");

			tdNumber = document.createElement("td");
			tdNumber.innerHTML = number;

			tdNickname = document.createElement("td");
			tdNickname.innerHTML = nickname;

			tdHead = document.createElement("td");
			tdHead.innerHTML = "<img width=50 src='"+headURL+"'>";
			tdScore = document.createElement("td");
			tdScore.innerHTML = score;
			console.log(headURL);
			trObj.appendChild(tdNumber);
			trObj.appendChild(tdNickname);
			trObj.appendChild(tdHead);
			trObj.appendChild(tdScore);

			tbody.appendChild(trObj);

		}
	});

</script>
</html>


